<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="java.net.URLDecoder"%>
<%@page import="java.net.URLEncoder"%>
<%
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ request.getContextPath() + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<title>Insert title here</title>
</head>
<body>
<h1>用戶信息：</h1>
<%request.setCharacterEncoding("utf-8");
//获取cookie的值
	String username = null;
    String password = null;
		Cookie[] cookies = request.getCookies();
		if(cookies!=null&&cookies.length>0) {//说明曾经保存过cookie
			for(Cookie c : cookies) { //判断是不是用户名或密码的Cookie对象
				if(c.getName().equals("username")) {//解码，解决无法在Cookie中保存中文字符串的问题
					username = URLDecoder.decode(c.getValue(),"utf-8");
				}else if(c.getName().equals("password")) {
					password = URLDecoder.decode(c.getValue(),"utf-8");
				}
			}
		}	
%>
用戶名：<%=username%> </br>
密碼：<%=password %>
</body>
</html>